home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / mach / port.h < prev    next >
Text File  |  1995-02-14  |  9KB  |  236 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    port.h,v $
  29.  * Revision 2.9  93/01/14  17:46:31  danner
  30.  *     Cleanup.
  31.  *     [92/06/10            pds]
  32.  *     64bit cleanup.
  33.  *     [92/12/01            af]
  34.  * 
  35.  * Revision 2.8  92/05/21  17:22:37  jfriedl
  36.  *     Appended 'U' to constants that would otherwise be signed.
  37.  *     [92/05/16            jfriedl]
  38.  * 
  39.  * Revision 2.7  92/01/15  13:44:48  rpd
  40.  *     Changed MACH_IPC_COMPAT conditionals to default to not present.
  41.  * 
  42.  * Revision 2.6  91/08/28  11:15:36  jsb
  43.  *     Added mach_port_seqno_t.  Added mps_seqno to mach_port_status_t
  44.  *     and created old_mach_port_status_t for compatibility purposes.
  45.  *     [91/08/09            rpd]
  46.  * 
  47.  * Revision 2.5  91/08/24  12:17:54  af
  48.  *     Added a set of parenthesis to MACH_PORT_TYPE to shut up gcc2.
  49.  *     [91/07/19            danner]
  50.  * 
  51.  * Revision 2.4.4.1  91/08/19  13:48:02  danner
  52.  *     Added a set of parenthesis to MACH_PORT_TYPE to shut up gcc2.
  53.  *     [91/07/19            danner]
  54.  * 
  55.  * Revision 2.4  91/05/14  16:58:38  mrt
  56.  *     Correcting copyright
  57.  * 
  58.  * Revision 2.3  91/02/05  17:35:27  mrt
  59.  *     Changed to new Mach copyright
  60.  *     [91/02/01  17:20:17  mrt]
  61.  * 
  62.  * Revision 2.2  90/06/02  14:59:44  rpd
  63.  *     Added mach_port_status_t.
  64.  *     [90/05/13            rpd]
  65.  *     Converted to new IPC.
  66.  *     [90/03/26  22:38:36  rpd]
  67.  * 
  68.  *
  69.  * Condensed history:
  70.  *    Put ownership rights under MACH_IPC_XXXHACK (rpd).
  71.  *    Put PORT_ENABLED under MACH_IPC_XXXHACK (rpd).
  72.  *    Removed PORT_INVALID (rpd).
  73.  *    Added port set, port name, port type declarations (rpd).
  74.  *    Added PORT_INVALID (mwyoung).
  75.  *    Added port_*_t types (mwyoung).
  76.  *    Added PORT_ENABLED (mwyoung).
  77.  *    Created (mwyoung).
  78.  */
  79. /*
  80.  *    File:    mach/port.h
  81.  *
  82.  *    Definition of a port
  83.  *
  84.  *    [The basic mach_port_t type should probably be machine-dependent,
  85.  *    as it must be represented by a 32-bit integer.]
  86.  */
  87.  
  88. #ifndef    _MACH_PORT_H_
  89. #define _MACH_PORT_H_
  90.  
  91. #import <mach/boolean.h>
  92. #import <mach/machine/vm_types.h>
  93.  
  94.  
  95. typedef natural_t mach_port_t;
  96. typedef mach_port_t *mach_port_array_t;
  97.  
  98. /*
  99.  *  MACH_PORT_NULL is a legal value that can be carried in messages.
  100.  *  It indicates the absence of any port or port rights.  (A port
  101.  *  argument keeps the message from being "simple", even if the
  102.  *  value is MACH_PORT_NULL.)  The value MACH_PORT_DEAD is also
  103.  *  a legal value that can be carried in messages.  It indicates
  104.  *  that a port right was present, but it died.
  105.  */
  106.  
  107. #define MACH_PORT_NULL        ((mach_port_t) 0)
  108. #define MACH_PORT_DEAD        ((mach_port_t) ~0)
  109.  
  110. #define    MACH_PORT_VALID(name)    \
  111.         (((name) != MACH_PORT_NULL) && ((name) != MACH_PORT_DEAD))
  112.  
  113. /*
  114.  *  These are the different rights a task may have.
  115.  *  The MACH_PORT_RIGHT_* definitions are used as arguments
  116.  *  to mach_port_allocate, mach_port_get_refs, etc, to specify
  117.  *  a particular right to act upon.  The mach_port_names and
  118.  *  mach_port_type calls return bitmasks using the MACH_PORT_TYPE_*
  119.  *  definitions.  This is because a single name may denote
  120.  *  multiple rights.
  121.  */
  122.  
  123. typedef natural_t mach_port_right_t;
  124.  
  125. #define MACH_PORT_RIGHT_SEND        ((mach_port_right_t) 0)
  126. #define MACH_PORT_RIGHT_RECEIVE        ((mach_port_right_t) 1)
  127. #define MACH_PORT_RIGHT_SEND_ONCE    ((mach_port_right_t) 2)
  128. #define MACH_PORT_RIGHT_PORT_SET    ((mach_port_right_t) 3)
  129. #define MACH_PORT_RIGHT_DEAD_NAME    ((mach_port_right_t) 4)
  130. #define MACH_PORT_RIGHT_NUMBER        ((mach_port_right_t) 5)
  131.  
  132. typedef natural_t mach_port_type_t;
  133. typedef mach_port_type_t *mach_port_type_array_t;
  134.  
  135. #define MACH_PORT_TYPE(right)        ((mach_port_type_t)(1 << ((right)+16)))
  136. #define MACH_PORT_TYPE_NONE        ((mach_port_type_t) 0)
  137. #define MACH_PORT_TYPE_SEND        MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
  138. #define MACH_PORT_TYPE_RECEIVE        MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
  139. #define MACH_PORT_TYPE_SEND_ONCE    MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE)
  140. #define MACH_PORT_TYPE_PORT_SET        MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET)
  141. #define MACH_PORT_TYPE_DEAD_NAME    MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
  142.  
  143. /* Convenient combinations. */
  144.  
  145. #define MACH_PORT_TYPE_SEND_RECEIVE                    \
  146.         (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
  147. #define    MACH_PORT_TYPE_SEND_RIGHTS                    \
  148.         (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
  149. #define    MACH_PORT_TYPE_PORT_RIGHTS                    \
  150.         (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
  151. #define    MACH_PORT_TYPE_PORT_OR_DEAD                    \
  152.         (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
  153. #define MACH_PORT_TYPE_ALL_RIGHTS                    \
  154.         (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
  155.  
  156. /* Dummy type bits that mach_port_type/mach_port_names can return. */
  157.  
  158. #define MACH_PORT_TYPE_DNREQUEST    0x80000000U
  159. #define MACH_PORT_TYPE_MAREQUEST    0x40000000
  160. #define    MACH_PORT_TYPE_COMPAT        0x20000000
  161.  
  162. /* User-references for capabilities. */
  163.  
  164. typedef natural_t mach_port_urefs_t;
  165. typedef integer_t mach_port_delta_t;            /* change in urefs */
  166.  
  167. /* Attributes of ports.  (See mach_port_get_receive_status.) */
  168.  
  169. typedef natural_t mach_port_seqno_t;        /* sequence number */
  170. typedef unsigned int mach_port_mscount_t;    /* make-send count */
  171. typedef unsigned int mach_port_msgcount_t;    /* number of msgs */
  172. typedef unsigned int mach_port_rights_t;    /* number of rights */
  173.  
  174. typedef struct mach_port_status {
  175.     mach_port_t        mps_pset;    /* containing port set */
  176.     mach_port_seqno_t    mps_seqno;    /* sequence number */
  177. /*mach_port_mscount_t*/natural_t mps_mscount;    /* make-send count */
  178. /*mach_port_msgcount_t*/natural_t mps_qlimit;    /* queue limit */
  179. /*mach_port_msgcount_t*/natural_t mps_msgcount;    /* number in the queue */
  180. /*mach_port_rights_t*/natural_t    mps_sorights;    /* how many send-once rights */
  181. /*boolean_t*/natural_t        mps_srights;    /* do send rights exist? */
  182. /*boolean_t*/natural_t        mps_pdrequest;    /* port-deleted requested? */
  183. /*boolean_t*/natural_t        mps_nsrequest;    /* no-senders requested? */
  184. } mach_port_status_t;
  185.  
  186. #define MACH_PORT_QLIMIT_DEFAULT    ((mach_port_msgcount_t) 5)
  187. #define MACH_PORT_QLIMIT_MAX        ((mach_port_msgcount_t) 16)
  188.  
  189. /*
  190.  *  Compatibility definitions, for code written
  191.  *  before there was an mps_seqno field.
  192.  */
  193.  
  194. typedef struct old_mach_port_status {
  195.     mach_port_t        mps_pset;    /* containing port set */
  196. /*mach_port_mscount_t*/natural_t mps_mscount;    /* make-send count */
  197. /*mach_port_msgcount_t*/natural_t mps_qlimit;    /* queue limit */
  198. /*mach_port_msgcount_t*/natural_t mps_msgcount;    /* number in the queue */
  199. /*mach_port_rights_t*/natural_t    mps_sorights;    /* how many send-once rights */
  200. /*boolean_t*/natural_t        mps_srights;    /* do send rights exist? */
  201. /*boolean_t*/natural_t        mps_pdrequest;    /* port-deleted requested? */
  202. /*boolean_t*/natural_t        mps_nsrequest;    /* no-senders requested? */
  203. } old_mach_port_status_t;
  204.  
  205.  
  206. /* Definitions for the old IPC interface. */
  207.  
  208. typedef integer_t    port_name_t;        /* A capability's name */
  209. typedef port_name_t    port_set_name_t;    /* Descriptive alias */
  210. typedef port_name_t    *port_name_array_t;
  211.  
  212. typedef integer_t    port_type_t;        /* What kind of capability? */
  213. typedef port_type_t    *port_type_array_t;
  214.  
  215.     /* Values for port_type_t */
  216.  
  217. #define PORT_TYPE_NONE        0        /* No rights */
  218. #define PORT_TYPE_SEND        1        /* Send rights */
  219. #define PORT_TYPE_RECEIVE    3        /* obsolete */
  220. #define PORT_TYPE_OWN        5        /* obsolete */
  221. #define PORT_TYPE_RECEIVE_OWN    7        /* Send, receive, ownership */
  222. #define PORT_TYPE_SET        9        /* Set ownership */
  223. #define PORT_TYPE_LAST        10        /* Last assigned */
  224.  
  225. typedef    port_name_t    port_t;            /* Port with send rights */
  226. typedef    port_t        port_rcv_t;        /* Port with receive rights */
  227. typedef    port_t        port_own_t;        /* Port with ownership rights */
  228. typedef    port_t        port_all_t;        /* Port with receive and ownership */
  229. typedef    port_t        *port_array_t;
  230.  
  231. #define PORT_NULL    ((port_name_t) 0)    /* Used to denote no port; legal value */
  232.  
  233. #import <mach/mach_param.h>
  234.  
  235. #endif    /* _MACH_PORT_H_ */
  236.